local huanshi = fk.CreateSkill{
    name = "gj_heg__huanshi",
}

local H = require "packages.ol_hegemony.util"

huanshi:addEffect(fk.AskForRetrial,{
    anim_type = "control",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(huanshi.name) and not player:isNude() and H.compareKingdomWith(target, player)
      end,
    on_cost = function(self, event, target, player, data)
        local card = player.room:askToCards(player,{
            min_num = 1,
            max_num = 1,
            include_equip = true,
            skill_name = huanshi.name,
            pattern = ".|.|.|hand,equip|.|",
            prompt = "#gj_heg__huanshi-ask::" .. target.id .. ":" .. data.reason,
            cancelable = true,
        })
        if #card > 0 then
          event:setCostData(self, {cards = card})
          return true
        end
      end,
    on_use = function(self, event, target, player, data)
        player.room:changeJudge{
          card = Fk:getCardById(event:getCostData(self).cards[1]),
          player = player,
          data = data,
          skill_name = huanshi.name,
          response = true,
        }
      end,
})

Fk:loadTranslationTable{
    ["gj_heg__huanshi"] = "缓释",
    [":gj_heg__huanshi"] = "当与你势力相同的角色的判定牌生效前，你可打出一张牌代替之。",
    ["#gj_heg__huanshi-ask"] = "缓释：你可打出一张牌代替 %dest 的 %arg 判定",

    ["$gj_heg__huanshi1"] = "缓乐之危急，释兵之困顿。",
    ["$gj_heg__huanshi2"] = "尽死生之力，保友邦之安。",
}

return huanshi